let arr1 = [1, 2, 3, 4];
let arr2 = [3, 4, 5, 6];

// 并集
let union = [...new Set([...arr1,...arr2])];
console.log(union); // 输出：[1 ,2 ,3 ,4 ,5 ，6]

//交集
let intersection = arr1.filter(x => new Set(arr2).has(x));
console.log(intersection); // 输出：[3, 4]

// 差集 (arr1 相对于 arr2 的差集)
let difference = arr1.filter(x => !new Set(arr2).has(x));
console.log(difference); // 输出：[1, 2]
